Skip to content

fix(daemon): name a sandbox-denied loopback listen and point at host access - #5081

Merged
thymikee merged 3 commits into
mainfrom
fix/daemon-listen-denied-hint
Nov 25, 2026
Merged

thymikee merged 3 commits into
mainfrom
fix/daemon-listen-denied-hint

Conversation

@thymikee

@thymikee thymikee commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Inside a coding-agent sandbox (for example Codex workspace-write), the daemon's loopback listen fails with listen EPERM. The CLI only said "Failed to start daemon … Read daemon.log", so agents gave up instead of asking for host access. The daemon now exits with a typed listen-denied code. The client reports startup-listen-denied, skips the retry, and the hint names the sandbox and the fix. The help and configuration docs list the new reason, and startup-exited now covers only other causes.

Before / after

sandbox-exec -p '(version 1)(allow default)(deny network-bind)' agent-device devices --platform ios

Before (0.21.41):

Error (COMMAND_FAILED): Failed to start daemon. Next: Daemon startup did not establish a reachable owner. Read daemon.log in the state directory. …

After:

Error (COMMAND_FAILED): Failed to start daemon. Next: The host denied the daemon a loopback port on 127.0.0.1 (listen EPERM or EACCES). A sandbox around this command likely blocks local ports and simulator access. Run agent-device outside the sandbox: allow the agent-device command in the agent's sandbox rules, or rerun it with host access (escalated permissions).

Validation

At 97ac3f4: pnpm gate fallow, pnpm typecheck, pnpm lint, and transport.test.ts (14 passed) all pass. daemon-client-startup-budget.test.ts passed at 98f5e77 and is unchanged since.
Live check at f8cda79 (same hint text): codex exec --approve-for-me with gpt-6-luna on an iOS simulator. Before: 0/2 runs asked for host access. After: 2/2 asked and opened the app. The second run then hit the first run's leftover device claim, a harness issue.
CI owns the full gates.

🤖 Generated with Claude Code

…access

A daemon whose loopback listen fails with EPERM or EACCES now exits with a
typed listen-denied code. The client reports startup-listen-denied, does not
retry, and its hint names the sandbox and the way out (allow agent-device in
the agent's sandbox rules, or rerun with host access).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.58 MB 6.58 MB +1.1 kB
Package (unpacked) 6.57 MB 6.58 MB +1.1 kB
Package (download) 2.01 MB 2.01 MB +459 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 65.9 ms 59.1 ms -6.7 ms
CLI --help 129.3 ms 109.6 ms -19.7 ms

Keeps startLocalDaemon under the Fallow cognitive-complexity ceiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The daemon change at 98f5e77 looks right, but the agent-facing help is now wrong for the exact case this PR targets.

The CLI help at https://github.com/callstack/agent-device/blob/98f5e77/src/commands/schema/cli-help.ts#L421 and https://github.com/callstack/agent-device/blob/98f5e77/website/docs/docs/configuration.md#L146 list startup-exited, startup-stalled and startup-ceiling as the startup outcomes to branch on. A denied listen now ends the process before it registers, with the new reason startup-listen-denied. An agent that follows the help handles only the three listed reasons, treats the new one as unknown, and never learns the host-access route. The PR updates only error-reasons.md. Please add startup-listen-denied (the host refused the daemon's loopback listen, as a sandbox around the command does; rerun with host access) to the list in both files, and narrow startup-exited to "the process ended before registering for another cause". The startup-exited row in error-reasons.md can get the same narrowing.

Not blocking, and fine to take or leave: the transport test at https://github.com/callstack/agent-device/blob/98f5e77/packages/daemon/src/server/http/transport.test.ts#L495 stops at the listen rejection, so nothing asserts that daemonStartupExitCode returns the listenDenied code (the busy case has that assertion at daemon-runtime-composition.test.ts:86); and the daemon_listen_denied reason set at https://github.com/callstack/agent-device/blob/98f5e77/packages/daemon/src/server/http/transport.ts#L235 has no reader, since the client keys on the exit code alone.

CI is green at this head. Body rules showed as cancelled in the first listing because editing the PR body cancels that job, and it passes on the later run. There are no conflicts. Not verified here: the CLI and daemon were not run under sandbox-exec at 98f5e77; only Node's listen EPERM under (deny network-bind) was confirmed. No device run is needed, since the change touches startup exit and error reporting only. Before merge, the help and docs fix above must land.

Narrows startup-exited to other causes in the help, the configuration page and
the reason table, and checks the listen-denied rejection through
daemonStartupExitCode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 97ac3f4

Since the review of 98f5e77: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (b2d4ec051109).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

At 97ac3f4 the code looks good, and the delta since the earlier review (98f5e77) only changes comments, help and docs strings and one test assertion. The earlier findings are now fixed, and no new problems were found. The listen path and the retry logic are unchanged since the earlier review, and they were re-read only to check the help and docs claims. Not verified here: the tests were not run locally. The only check that is not passing is Body rules, which was cancelled; it validates the PR description and metadata rather than code, and it looks like a superseded run. Re-running it should settle that, and once it passes the PR is ready to merge. No conflicts.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee
thymikee merged commit c8555bd into main Nov 25, 2026
21 of 22 checks passed
@thymikee
thymikee deleted the fix/daemon-listen-denied-hint branch November 25, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant